package cpt202.project.Interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//定义一个拦截器
public class loginInterceptor implements HandlerInterceptor {
    //在调用所有处理请求的方法之前执行
    @Override
    //True :放行   False: 拦截
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object ema = request.getSession().getAttribute("email");
        if(ema==null){
            response.sendRedirect("/web/登录.html");
            return false;
        }
       return true;
    }



}
